#include "PE1_winec.h"

// #include <valarray>
// #include <string>
// #include <iostream>

// using std::valarray;
// using std::string;
// using std::cout;
// using std::cin;
// using std::endl;

Wine::Wine(const char*l,int y,const int yr[],const int bot[])
    :name(l),years(y),pa(PairArray(ArrayInt(yr,y),ArrayInt(bot,y)))
{
}

Wine::Wine(const char*l,int y)
    :name(l),years(y),pa(PairArray(ArrayInt(0),ArrayInt(0)))
{
}

void  Wine::Show() const
{
    cout << "Wine:" << name << endl;
    cout << "\tYear\tBottles\n";
    for (int i = 0; i < years; ++i)
    {
        cout <<"\t"<< pa.year[i] << "\t" << pa.bottle[i] << endl;
    }
}

void  Wine::GetBottles(){
    pa.bottle.resize(years);
    pa.year.resize(years);
    cout << "Enter " << years << " data for " << name << endl;
    for (size_t i = 0; i < years; i++)
    {
        cout << "Enter year:";
        cin >> pa.year[i];
        cout << "Enter bottles for that year:";
        cin >> pa.bottle[i];
    }
}

string Wine::Label() const
{
    return name;
}

int Wine::sum() const
{
    return pa.bottle.sum();
}